package com.hall.controller;

import com.hall.pojo.Answer;
import com.hall.pojo.Appointment;
import com.hall.pojo.SysUser;
import com.hall.service.AnswerService;
import com.hall.service.AttentionServes;
import com.hall.service.UserService;
import com.hall.utils.UserSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;


@Controller
@RequestMapping("/answer")
public class AnswerController {
    @Autowired
    private AnswerService answerService;
    @RequestMapping(value = "form")
    public String answerform(String appointmentId,String userId, Model model){
        model.addAttribute("appointmentId",appointmentId);
        model.addAttribute("userId",userId);
        return "answerform";
    }
    @RequestMapping("save")
    @ResponseBody
    public String saveAnswer(Answer answer){
        answerService.saveAnswer(answer);
        return "OK";
    }
    @RequestMapping("list")
    public String answerlist(String appointmentId,String userId,Model model){
       List<Answer> answerList=answerService.answerList(appointmentId,userId);
        model.addAttribute("answerlist",answerList);
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+appointmentId+">>>>>>>>>>>>>>>>>>>>>>>>>>"+userId);
        return "answerlist";
    }
}
